<?php
	session_start();
	require("user_type/member.php");
	include("user_type/system.php");
	
	$userID = intval($_SESSION['ID']);
	$counter = intval($_POST['counter']);
	$filetype = 'art';
	
	//print_r($_POST);
	for($i=1; $i<=$counter; $i++){
		$newname = "newartname".$i;
		$oldname = "oldartname".$i;
		if(isset($_POST[$newname])){
			$newfilename ="articles/".$_POST[$newname];
			if(!empty($newfilename)){
				$oldfilename = $_POST[$oldname];
				if(Member::updateFile($oldfilename, $newfilename, $filetype) == -1){
					echo "You File have Unacceptable or stopword. 0.2 point will be reduced form your credits";
					System::reduceCredits($userID);
				}
				elseif(Member::updateFile($oldfilename, $newfilename, $filetype) == -2)
					echo "A filetype must be specified.  <br> <a href=\"home.php\">Go to Home Page</a> <br><a href=\"userInfo.php\">View Profile</a>";
				else{
					echo "Your article has been updated. Thank You.  <br> <a href=\"home.php\">Go to Home Page</a> <br><a href=\"userInfo.php\">View Profile</a>";
				}		
			}
			else
				echo "You must select a file in order to update. <br> <a href=\"home.php\">Go to Home Page</a> <br><a href=\"userInfo.php\">View Profile</a>";	
		}
	}	
?>